package com.bjwl.web.contrlller.branchstore;

import com.bjwl.pojo.Bsadmin;
import com.bjwl.pojo.ServiceClass;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.ServerClassService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/9 13:50
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Controller
@RequestMapping("/bsClass")
public class ServiceClassControllerabc {

    @Autowired
    private ServerClassService serverClassService;

    @RequestMapping("/findAllServiceClass")
    public String findAllCardDenomination(BasicQueryVo vo, Model model){
        PageBean<ServiceClass> pageBean = serverClassService.findAllServiceClass(vo);
        model.addAttribute("pageBean",pageBean);
        return "branch_oa/worktype-list";
    }

    @RequestMapping("/addServiceClass")
    public @ResponseBody
    boolean addServiceClass(@RequestBody ServiceClass ServiceClass, HttpSession httpSession){
        Bsadmin bsadmin = (Bsadmin) httpSession.getAttribute("bsadmin1");
        ServiceClass.setBsid(bsadmin.getBsid());
        return serverClassService.addServiceClass(ServiceClass);
    }

    /**
     * 修改前回显
     * @param
     * @return
     */
    @RequestMapping("/updateServiceClassS")
    public String updateServiceClassS(Integer id, Model model){
        model.addAttribute("ServiceClass",serverClassService.editStart(id));
        return "branch_oa/worktype-edit";
    }

    /**
     * 修改
     * @param
     * @return
     */
    @RequestMapping("/updateServiceClass")
    public @ResponseBody
    boolean updateCardDenomination(@RequestBody ServiceClass ServiceClass){
        serverClassService.updateServiceClass(ServiceClass);
        return true;
    }

    /**
     * 修改
     * @param
     * @return
     */
    @RequestMapping("/deleteServiceClass")
    public @ResponseBody
    boolean deleteServiceClass(@RequestBody Integer id){

        return serverClassService.deleteServiceClass(id);
    }

}
